﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BirthdayBless.aspx.cs" Inherits="Web.BirthdayBless" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
    <script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script>
    <link href="Content/scripts/plugIn/Pagination/style.css" rel="stylesheet" type="text/css" />
    <link href="Content/scripts/plugIn/Pagination/core.css" rel="stylesheet" type="text/css" />
    <script src="Content/scripts/plugIn/Pagination/core.js" type="text/javascript"></script>
    <script src="Content/scripts/plugIn/Pagination/pagination.js" type="text/javascript"></script>
    <script>
        //取get参数
        function getArg() {
            var url = unescape(window.location.href);
            var allArgs = url.split("?")[1];
            if (allArgs != null) {
                var args = allArgs.split("&");
                for (var i = 0; i < args.length; i++) {
                    var arg = args[i].split("=");
                    eval('this.' + arg[0] + '="' + arg[1] + '";');
                }
            }
        }
        var urlArg = new getArg();

        DWZ.init("Content/scripts/plugIn/Pagination/pagination.xml");
        $(function () {
            if (urlArg.numPerPage != undefined) {
                $("#numPerPage").val(urlArg.numPerPage);
            }
            setTimeout(paginationRender, 600);
        });
        function paginationRender() {
            $("div.pagination").each(function () {
                var $this = $(this);
                $this.pagination({
                    totalCount: $this.attr("totalCount"),
                    numPerPage: $this.attr("numPerPage"),
                    pageNumShown: $this.attr("pageNumShown"),
                    currentPage: $this.attr("currentPage")
                });
            });
        }
        function PageBreak(args) {
            //alert(args["pageNum"] || args["numPerPage"]);
            if (args["pageNum"] == undefined) { args["pageNum"] = $("li.selected a").text(); }
            if (args["numPerPage"] == undefined) { args["numPerPage"] = $("#numPerPage").val(); }
            location.href = "BirthdayBless.aspx?empId=" + urlArg.empId + "&pageNum=" + args["pageNum"] + "&numPerPage=" + args["numPerPage"];
        }
        function fnBless() {
            var blessContent =$("#txtBlessContent").val();
            if(blessContent==''){alert('请填写祝福内容!');return;}
            var record= {
                EmpId: urlArg.empId,
                BlessContent: blessContent
            };
            Ext.Ajax.request({
                url: '/Birthday.mvc/Add',
                method: 'POST',
                success: function (response, options) {
                    var responseMessage = Ext.util.JSON.decode(response.responseText);
                    if (responseMessage.Result) {
                        alert('数据保存成功！');
                        location.href = 'BirthdayBless.aspx?empId=' + urlArg.empId;
                    }
                    else {
                        alert('数据保存失败，请您重试！');
                    }
                },
                params: {
                    json: Ext.util.JSON.encode(record)
                },
                failure: function (form, action) {
                    if (action.failureType == 'server') {
                        obj = Ext.util.JSON.decode(action.response.responseText);
                        alert(obj.errors.reason);
                    }
                    if (action.failureType == 'client') {
                        alert('数据不正确，请核对后重新操作');
                    }
                }
            });
        }
    </script>
    <style>
    body{width:644px;margin:0 auto;border:#369 solid 1px;}
    .header{font-size:18px;margin:24px auto 6px auto;}
    a.buttonActive,a.button{margin:6px;margin-right:24px;float:right;}
    
    dl{text-align:left;width:100%;}
    dt,dd{padding-left:24px;}
    dt{background:url(Content/images/bg_n_remark.png) repeat-x;border-top:#369 1px solid;}
    dt span{color:#369;border-bottom:#369 1px solid;line-height:24px;}
    dd{line-height:24px;text-indent:2em;}
    </style>
	<script src="Content/scripts/extjs/adapter/ext/ext-base.js"></script>
	<script src="Content/scripts/extjs/ext-all.js"></script>
</head>
<body>
<div class="header">生日祝福</div>
<img src='Photoes/<%=photoName%>' style="width:120px;height:150px;float:left;margin-left:24px;"/>
<textarea id="txtBlessContent" name="txtBlessContent" cols="64" rows="7" class="textInput"></textarea>
    <a class="button" href="javascript:window.close();"><span>关闭</span></a>
    <a class="buttonActive isDisplay" href="javascript:fnBless();"><span>祝福</span></a>
    <form runat="server">
    <asp:Repeater ID="rptList" EnableViewState="False" Runat="server">
		<HeaderTemplate>
			<dl>
		</HeaderTemplate>
		<ItemTemplate>
            <dt><span><strong>第<%#Model.TotalCount-Container.ItemIndex-(Model.CurrentPage - 1) * Model.NumPerPage%>楼</strong> <%# DataBinder.Eval(Container.DataItem, "FromName") + " 时间 " + DataBinder.Eval(Container.DataItem, "BlessDate")%></span></dt>
            <dd><%# DataBinder.Eval(Container.DataItem, "BlessContent")%></dd>
		</ItemTemplate>
		<FooterTemplate>
			</dl>
		</FooterTemplate>
	</asp:Repeater>
    </form>
    <div class="panelBar">
        <div class="pages">
            <span>显示</span>
            <select id="numPerPage" name="numPerPage" onchange="javascript:PageBreak({numPerPage:this.value});">
                <option value="5">5</option>
                <option value="10">10</option>
                <option value="15">15</option>
                <option value="20">20</option>
                <option value="30">30</option>
                <option value="50">50</option>
                <option value="100" selected="selected">100</option>
            </select>
            <span>条，共 <%= Model.TotalCount%> 条</span>
        </div>
        <div class="pagination" totalcount="<%= Model.TotalCount%>" numperpage="<%= Model.NumPerPage%>" pagenumshown="<%= Model.PageNumShown%>" currentpage="<%= Model.CurrentPage%>"></div>
    </div>
</body>
</html>